package info.techgeek.labs.java5Features.thread.cifortify;

import java.util.Random;
import java.util.logging.Logger;


/**
 * CRQToTaskThreadPoolReader Execute when thread pool execute from listner
 * 
 * @author techgeek
 * 
 */
public class FortifyThreadPoolReader implements Runnable {
	
	private int index ;
	
	/**
	 * Issue is created using API when CRQTOTask listner fires.
	 */
	public void run() {

		System.out.println("Count "+index);
		
		System.out.println("******************************************************");
		System.out.println("*  FortifyThreadPoolReader Started********************");
		System.out.println("*******************************************************");
		
		for (int i = 0; i <= 100; i += 10) {
        	int random = new Random().nextInt(5);
//        	System.out.println("Client random "+random);
        	int num =( random + 1) * 1000; 
//        	System.out.println("Client num "+num);
           sleep(num);
           System.out.println(String.format("request: %d completed: %d%%", index, i));
        }
        System.out.println(String.format("reqest %d completed", index));

	}
	
	
	private void sleep(int millis) {
//	   System.out.println("Client sleep millis "+millis);
      try {
         Thread.sleep(millis);
      }
      catch (InterruptedException e) {

      }
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	
	
}

